#include "VertexBuffer.hpp"


VertexBuffer::VertexBuffer(unsigned int type):
m_Type(type)
{
	glGenVertexArrays(1, &m_VertexArray);
	glGenBuffers(1, &m_Buffer);
}

VertexBuffer::~VertexBuffer()
{
	glDeleteBuffers(1, &m_Buffer);
	glDeleteVertexArrays(1, &m_VertexArray);
}

void VertexBuffer::Draw(unsigned int primitiveType)
{
	glBindVertexArray(m_VertexArray);
	glDrawArrays(primitiveType, 0, m_NumVertices);
}

void VertexBuffer::SetLocation(unsigned int location, unsigned int offset, unsigned int size, unsigned int stride)
{
	glBindVertexArray(m_VertexArray);
	glBindBuffer(m_Type, m_Buffer);
	glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE, stride, (void*)offset);
	glEnableVertexAttribArray(location);
}
